if(BUILD_TARGET STREQUAL "buildsdk")
    file(GLOB_RECURSE SOURCES "*.h" "*.cpp")
    # 创建库
    add_library(isc-lib-lidar SHARED ${SOURCES})
    set_target_properties(
        isc-lib-lidar PROPERTIES
        BUILD_RPATH "/usr/lib/x86_64-linux-gnu;usr/local/lib"
    )

    target_compile_definitions(isc-lib-lidar PRIVATE ISCLIBLIDAR_EXPORTS)
    # 设置库的头文件路径
    target_include_directories(isc-lib-lidar PUBLIC 
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/../../deps
    )

    if(WIN32)
        #pcap
        set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
        find_package(PCAP REQUIRED)
        # rs_driver
        set(RS_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../deps/rs_driver")
        target_include_directories(isc-lib-lidar PUBLIC ${RS_DRIVER_PATH})
        # pcl
        find_package(PCL REQUIRED)
        # opencv
        find_package(Opencv REQUIRED)

        target_include_directories(isc-lib-lidar PUBLIC ${PCAP_INCLUDE_DIR} ${RS_DRIVER_PATH} ${OpenCV_INCLUDE_DIRS})
        target_link_libraries(isc-lib-lidar PUBLIC ${PCAP_LIBRARY} ${OpenCV_LIBS})
    else()
        # rs_driver
        find_package(rs_driver REQUIRED)
        target_include_directories(isc-lib-lidar PUBLIC ${rs_driver_INCLUDE_DIRS})
        target_link_libraries(isc-lib-lidar PUBLIC ${rs_driver_LIBRARIES} )
        # pcl
        set(PCL_DIR "/home/school/lib/pcl-1.13/share/pcl-1.13")
        find_package(PCL 1.13.1 REQUIRED)
    endif()
    find_package(Poco REQUIRED COMPONENTS Foundation)
    target_include_directories(isc-lib-lidar PUBLIC ${PCL_INCLUDE_DIRS})
    target_link_libraries(isc-lib-lidar PUBLIC ${PCL_LIBRARIES} Poco::Foundation)
    target_link_libraries(isc-lib-lidar PUBLIC isc-lib-utils)

    set_target_properties(isc-lib-lidar PROPERTIES DEBUG_POSTFIX "d")

    set_target_properties(isc-lib-lidar PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY_DEBUG  ${CMAKE_SOURCE_DIR}/libs/bin/debug
        RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/libs/bin/release
        ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/libs/lib/debug
        ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/libs/lib/release
        LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/libs/lib/debug
        LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/libs/lib/release
    )

    if(WIN32)
        # 添加预处理器定义以避免Windows头文件冲突
        target_compile_definitions(isc-lib-lidar PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
        target_compile_definitions(isc-lib-utils PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
    endif()

elseif(BUILD_TARGET STREQUAL "demo")
    file(GLOB_RECURSE SOURCES "*.h" "*.cpp")

    find_package(CUDA)
    if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
        set(CMAKE_CUDA_ARCHITECTURES 70 75 80)
    endif()
    set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_50,code=\"sm_50,compute_50\")
    if ( CMAKE_COMPILER_IS_GNUCC )
        if(NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" )
            list(APPEND CUDA_NVCC_FLAGS -std=c++11)
        endif()
    endif()
    enable_language(CUDA)

    # set(cuPCL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../cuPCL/include)
    # set(cuPCL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/../cuPCL/lib/libcudafilter.so)

    # 创建库
    add_library(isc-lib-lidar STATIC ${SOURCES})
    set_target_properties(
        isc-lib-lidar PROPERTIES
        BUILD_RPATH "/usr/lib/x86_64-linux-gnu;usr/local/lib"
    )
    target_compile_definitions(isc-lib-lidar PRIVATE DEMO_BUILD)
    target_include_directories(isc-lib-lidar PUBLIC 
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/../../deps
    )

    find_package(Poco REQUIRED COMPONENTS Foundation)
    
    if(WIN32)
        #pcap
        set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
        find_package(PCAP REQUIRED)
        # rs_driver
        set(RS_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../deps/rs_driver")
        target_include_directories(isc-lib-lidar PUBLIC ${RS_DRIVER_PATH})
        # pcl
        find_package(PCL REQUIRED)
        # opencv
        find_package(Opencv REQUIRED)

        target_include_directories(isc-lib-lidar PUBLIC ${PCAP_INCLUDE_DIR} ${RS_DRIVER_PATH} ${OpenCV_INCLUDE_DIRS})
        target_link_libraries(isc-lib-lidar PUBLIC ${PCAP_LIBRARY} ${OpenCV_LIBS})
    else()
        # rs_driver
        find_package(rs_driver REQUIRED)
        target_include_directories(isc-lib-lidar PUBLIC ${rs_driver_INCLUDE_DIRS})
        target_link_libraries(isc-lib-lidar PUBLIC ${rs_driver_LIBRARIES} )
        # pcl
        set(PCL_DIR "/home/school/lib/pcl-1.13/share/pcl-1.13")
        find_package(PCL 1.13.1 REQUIRED)
        # opencv
        set(OpenCV_DIR "/home/school/cxz/Projects/percipient-service/deps/OpenCV/opencv4.5.5_contrib_install/lib/cmake/opencv4")
        find_package(OpenCV REQUIRED PATHS /home/school/cxz/Projects/percipient-service/deps/OpenCV/opencv4.5.5_contrib_install/lib/cmake/opencv4)
    endif()

    # 设置库的头文件路径
    target_include_directories(isc-lib-lidar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

    add_definitions("-DENABLE_TRANSFORM")

    target_include_directories(isc-lib-lidar PUBLIC ${PCL_INCLUDE_DIRS} ${rs_driver_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS} ${cuPCL_INCLUDE_DIRS})
    target_link_libraries(isc-lib-lidar PUBLIC ${PCL_LIBRARIES} ${rs_driver_LIBRARIES} Poco::Foundation)
    target_link_libraries(isc-lib-lidar PUBLIC isc-lib-utils)
    target_link_libraries(isc-lib-lidar PUBLIC ${OpenCV_LIBS})
    if(MSVC)
    else()
        target_link_libraries(isc-lib-lidar PUBLIC ${CUDA_CUDA_LIBRARY} rt dl pthread)
    endif()
    #target_link_libraries(isc-lib-lidar PUBLIC ${CUDA_CUDA_LIBRARY} cudart_static rt dl pthread cudart)
    #target_link_libraries(isc-lib-lidar PUBLIC ${cuPCL_LIBRARIES})

    if(WIN32)
        # 添加预处理器定义以避免Windows头文件冲突
        target_compile_definitions(isc-lib-lidar PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
        target_compile_definitions(isc-lib-utils PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
    endif()
elseif(BUILD_TARGET STREQUAL "demo2")
    file(GLOB_RECURSE SOURCES "*.h" "*.cpp")

    find_package(rs_driver REQUIRED)
    set(PCL_DIR "/home/school/lib/pcl-1.13/share/pcl-1.13")
    find_package(PCL 1.13.1 REQUIRED)
    find_package(Poco REQUIRED COMPONENTS Foundation)
    set(OpenCV_DIR "/home/school/cxz/Projects/percipient-service/deps/OpenCV/opencv4.5.5_contrib_install/lib/cmake/opencv4")
    find_package(OpenCV REQUIRED PATHS /home/school/cxz/Projects/percipient-service/deps/OpenCV/opencv4.5.5_contrib_install/lib/cmake/opencv4)

    # set(cuPCL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../cuPCL/include)
    # set(cuPCL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/../cuPCL/lib/libcudafilter.so)

    # 创建库
    add_library(isc-lib-lidar ${SOURCES})
    # 设置库的头文件路径
    target_include_directories(isc-lib-lidar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

    add_definitions("-DENABLE_TRANSFORM")

    target_include_directories(isc-lib-lidar PUBLIC ${PCL_INCLUDE_DIRS} ${rs_driver_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
    target_link_libraries(isc-lib-lidar PUBLIC ${PCL_LIBRARIES} ${rs_driver_LIBRARIES} Poco::Foundation)
    target_link_libraries(isc-lib-lidar PUBLIC isc-lib-utils)
    target_link_libraries(isc-lib-lidar PUBLIC ${OpenCV_LIBS})

    message(STATUS "RS_DRIVER_INCLUDE_DIRS: ${rs_driver_INCLUDE_DIRS}")
    message(STATUS "RS_DRIVER_LIBRARIES: ${rs_driver_LIBRARIES}")
endif()
